#!/usr/bin/env python
# -*- coding:utf-8 -*-

# file:do_auth_decorator.py
# author:张世航
# datetime:2024/11/10 17:09
# software: PyCharm
"""
this is function  description 
"""
# import module your need

# 3  编写一个装饰器，为多个函数加上认证的功能（必须输入用户的账号密码，才能调用这个函数）
import functools

def auth_decorator(required_username, required_password):
    def decorator(func):
        @functools.wraps(func)
        def wrapper(*args, **kwargs):
            username = input("Username: ")
            password = input("Password: ")
            if username == required_username and password == required_password:
                result = func(*args, **kwargs)
                return result
            else:
                print("Access Denied!")
        return wrapper
    return decorator

# 示例
@auth_decorator("admin", "1234")
def example_function():
    print("Welcome, admin!")

example_function()